<template>
	<view class="">
		<line-home v-if="type == 1" ref="line"></line-home>
		<offline-home  v-if="type == 2" ref="offline"></offline-home>
	</view>
</template>

<script>
import lineHome from '@/pages/line/home/index'
import offlineHome from '@/pages/offline/home/index'
export default {
	components:{
		lineHome,
		offlineHome
	},
	data() {
		return {
			type: ''
		}
	},
	mounted() {
		this.type = uni.getStorageSync('type') //1线上 2线下
		if (this.type == 1) {
			this.initLine()
		} else if (this.type == 2) {
			this.initOffline()
		}
	},
	// 下拉刷新事件只能写在父组件页面
	onPullDownRefresh() {
		if (this.type == 1) {
			this.$refs.line.getNotice();
			this.$refs.line.getMerchantInfo();
			this.$refs.line.getOrderAmountStatistics();
			this.$refs.line.getProductDataStatistics();
			this.$refs.line.getOrderNumStatistics();
		} else if (this.type == 2) {
			this.$refs.offline.getNotice();
			this.$refs.offline.getProductDatas();
			this.$refs.offline.getDataAnalysis();
		}
	},
	methods: {
		initOffline() {
			uni.setTabBarItem({
			  index: 1,
			  pagePath: '/pages/offline/shoping/index',
			})
			uni.setTabBarItem({
			  index: 2,
			  text: '应用',
			  "iconPath": "static/system/6.png",
			  "selectedIconPath": "static/system/66.png",
			  pagePath: '/pages/offline/application/index',
			})
			uni.setTabBarItem({
			  index: 3,
			  pagePath: '/pages/offline/order/index',
			})
			uni.setTabBarItem({
			  index: 4,
			  pagePath: '/pages/offline/my/index',
			})
		},
		initLine() {
			uni.setTabBarItem({
			  index: 1,
			  pagePath: '/pages/line/shoping/index',
			})
			uni.setTabBarItem({
			  index: 2,
			  text: '分配',
			  "iconPath": "static/system/3.png",
			  "selectedIconPath": "static/system/33.png",
			  pagePath: '/pages/line/merchant/index',
			})
			uni.setTabBarItem({
			  index: 3,
			  pagePath: '/pages/line/order/order',
			})
			uni.setTabBarItem({
			  index: 4,
			  pagePath: '/pages/line/my/index',
			})
		},
	}
}
</script>

<style>
</style>
